	<script type="text/javascript" src="md5.js"></script>
	<script type="text/javascript" src="code.js"></script>
</head>
<body>
<script>
if (document.URL.indexOf("?") > -1 ) history.pushState(null, null, document.URL.slice(0,document.URL.indexOf("?")));
//remove unnecessary link part (after "?")
/*?REDIR
	history.pushState(null, null, "%TO%"); //Or change link to page to has been redirect
/*REDIR?*/
function getCookie(name){
//http://stackoverflow.com/questions/4825683/how-do-i-create-and-read-a-value-from-cookie (17.02.2013.)
var i, x, y, ARRcookies = document.cookie.split(";");
	for (i = 0; i < ARRcookies.length; i++){
		x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
		y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x = x.replace(/^\s+|\s+$/g,"");
		if (x == name){
			return unescape(y);
		}
	}
}
window.onload = function (){
	SetSma();//Set sma to input field if needed
	SetSid();//Set encoded sid to input field  and to cookie if needed 
	Coded();//decrypts encode information
	Md5();//Encrypts input fiels to prove identity when data are sent
}
reset()
setInterval( "reset()", 50000 );//Sid may chaneged while page is open
function reset()
{
	SetSma();//Set sma to input field if needed
	SetSid();//Set encoded sid to input field  and to cookie if needed
	Md5();//Encrypts input fiels to prove identity when data are sent
}
function SetSma(){//Set sma to input field if needed
	var elems = document.getElementsByTagName('input'), i;
	var sma = getCookie("Msma37");
	if (sma == undefined) sma="";
	for (i = 0; i < elems.length; i++) {
		if((' ' + elems[i].className + ' ').indexOf(' Msma37 ') > -1) {
			elems[i].value = sma;
		}
	}
}
function SetSid(){//Set encoded sid to input field and to cookie if needed
	var elems = document.getElementsByTagName('input'), i;
	var sma = getCookie("Msma37");
	if (sma == undefined) return;
	var sid = localStorage.getItem("Msid37");
	if(sid == null) return;
	sid = hex_md5(sid + sma);
	document.cookie = 'Msid37=' + sid + '; expires=Session; path=/'
	for (i = 0; i < elems.length; i++) {
		if((' ' + elems[i].className + ' ').indexOf(' Msid37 ') > -1) {
			elems[i].value = sid;
		}
	}
}
function Coded(){//decrypts encode information
	var elems = document.getElementsByTagName('span'), i;
	for (i = 0; i < elems.length; i++) {
		if((' ' + elems[i].className + ' ').indexOf(' coded ') > -1) {
			elems[i].innerHTML = fromCode(elems[i].innerHTML, elems[i].id);
			elems[i].style.display = "inline";
			//Data is hidden while it encoded to be more visually appealling 
		}
	}
	elems = document.getElementsByTagName('input');
	for (i = 0; i < elems.length; i++) {
		if((' ' + elems[i].className + ' ').indexOf(' coded ') > -1) {
			elems[i].value = fromCode(elems[i].value, elems[i].id);
			elems[i].style.display = "inline";
			//Data is hidden while it encoded to be more visually appealling
		}
		if((' ' + elems[i].className + ' ').indexOf(' list ') > -1) {
			//in case of drop-down box
			document.getElementById(elems[i].name).value = elems[i].value;
			//hidden field name == select id
		}
		if((' ' + elems[i].className + ' ').indexOf(' bool ') > -1 && elems[i].value == "True") {
			//in case check box
			document.getElementById(elems[i].name).checked = true;
			//hidden field name == check box id
		}
	}
}
function Md5(){//Encrypts input fiels to prove identity when data are sent
	var elems = document.getElementsByTagName('input'), i;
	var sma = getCookie("Msma37");
	if (sma == undefined) return;
	var sid = localStorage.getItem("Msid37");
	if(sid == null) return;
	for (i in elems) {
		if((' ' + elems[i].className + ' ').indexOf(' md5 ') > -1) {
			elems[i].value = hex_md5(sid + sma + elems[i].id);
		}
	}
}
	document.cookie = 'Msma37=%RAND%; expires=Session; path=/' <!--Set sma to cookies-->
	/*?LOGIN
		var cod = localStorage.getItem("Mcod37");
		var sid = %SID%;
		cod = parseInt(cod,16);
		sid = sid + cod;
		sid = sid + "";
		localStorage.setItem("Msid37", hex_md5(sid));
	/*LOGIN?*/
	/*?DEL
		document.cookie = 'Msid37=0; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/' <!--delete cookie by expiring it-->
		try{localStorage.removeItem("Msid37");}catch(err){}
	/*DEL?*/
	try{localStorage.removeItem("Mcod37");}catch(err){}

</script>